<?php

	/**
	 * @see Bike_Form_Renderer_ExtJs_Abstract
	 */
	require_once 'Bike/Form/Renderer/ExtJs/Abstract.php';
	
	/**
	 * @see Bike_Form_Renderer_ExtJs
	 */
	require_once 'Bike/Form/Renderer/ExtJs.php'; 
	
	
	abstract class Bike_Form_Renderer_ExtJs_Element extends Bike_Form_Renderer_ExtJs_Abstract
	{
		protected function getExtJsSettings()
		{
			$settings = array();
			
			foreach($this->getElement()->getValidators() as $Validator)
			{
				try
				{
					$className = Bike_Form_Renderer_ExtJs::getHandler(get_class($Validator));
					$Handler = new $className();
					if(!$Handler instanceof Bike_Form_Renderer_ExtJs_Field_Validate_Abstract)
					{
						require_once 'Bike/Form/Renderer/Exception.php';
						throw new Bike_Form_Renderer_Exception('Class "'.$className.'" is not instance of Bike_Form_Renderer_ExtJs_Field_Validate_Abstract');
					}
					$settings = array_merge($settings, (array) $Handler->setValidator($Validator)->getSettings());
				}
				catch(Bike_Form_Renderer_Exception $e)
				{
				}
			}

			return array_merge((array) parent::getExtJsSettings(), (array) $this->getElement()->getSettings(), (array) $settings, array(
				'name' => $this->getElement()->getName(),
			));
		}
	}
